package com.talent.service.impl;

import com.talent.entities.dto.Vacc;
import com.talent.mapper.VaccListMapper;
import com.talent.service.VaccListService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedList;

/**
 * @author 周意朗
 * Date: 2022/4/16
 * @since JDK 11
 */
@Service
public class VaccListServiceImpl implements VaccListService {
    @Resource
    VaccListMapper mapper;

    /**
     * 得到疫苗表
     *
     * @param index 索引
     * @return 查询到的疫苗表
     */
    @Override
    public LinkedList<Vacc> getVaccList(int index) {
        return mapper.getVaccList(index * 10, index * 10 + 9);
    }

    @Override
    public LinkedList<Vacc> getVaccListByCondition(int age, int type, int gender, int index) {
        return mapper.getVaccListByCondition(age, type, gender, index * 10, index * 10 + 9);
    }

    /**
     * 按照输入来模糊查询疫苗种类并且返回
     *
     * @param index 索引
     * @param input 输入
     * @return 查询的列表
     */
    @Override
    public LinkedList<Vacc> getVaccListBySearch(String input, int index) {
        return mapper.getVaccListBySearch(input, index * 10, index * 10 + 9);
    }

    @Override
    public LinkedList<Vacc> getVaccListByserachAdmin(String input, int index) {
        return mapper.getVaccListBySearch(input, index * 10, index * 10 + 9);
    }

    /**
     * 添加疫苗
     *
     * @param addedVacc 疫苗
     * @return 是否成功
     */
    @Override
    public Boolean addVaccByAdmin(Vacc addedVacc) {
        return mapper.addVaccByAdmin(addedVacc);
    }

    /**
     * 修改疫苗
     *
     * @param vacc 疫苗
     * @return 是否成功
     */
    @Override
    public Boolean updateVacc(Vacc vacc) {
        return mapper.updateVacc(vacc);
    }

    @Override
    public Vacc searchById(String id) {
        return mapper.searchById(id);
    }
}
